#include <stdio.h>

int main() {
	int a[50] = {0}, x = 0, y = 0, n, m, l = 0;
	scanf("%d", &m);
	scanf("%d", &n);
	while (l < m - 1) {
		if (a[y] == 0)	{
			x = x + 1;
			if (x == n) {
				a[y] = 1;
				l = l + 1;
				x = 0;
			}
		}
		if (y == m - 1)
			y = -1;
		y = y + 1;
	}
	for (x = 0; x < m; x++) {
		if (a[x] == 0) {
			printf("The king is monkey:%d", x + 1);
			break;
		}
	}
}